<html><head>
<style>
fieldset{
	border-width: 1;
	border-radius: 5;
	border-style: solid;
	margin: 5;
	vertical-align: top;
}
</style>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  <title>
    GHTML Presents: SQLite - sql.js
  </title>
  <script src="sql_files/sql.js"></script>
  <script>
	var ghtml = ghtmlRunTime();
	console.exec = ghtml.console.exec;
	console.print = ghtml.console.print;
	console.error = ghtml.console.error;
    // Open a database
    var db = SQL.open();

    // Run a command in the database
    function execute(commands) {
      try {
        var data = db.exec(commands.replace(/\n/g, '; '));
        console.print(JSON.stringify(data, null, '  '));
      } catch(e) {
        console.error(e);
      }
    }
  </script>
</head>
<body style="font-size: 10pt;" onload="window.resizeTo(625, 295)">
  <p>
    This is <a href="http://www.sqlite.org/">SQLite</a> compiled from C to JavaScript using <a href="http://emscripten.org/">Emscripten</a>. Adapted for GHTML. 
  </p>
  <p>
    </p>
  <fieldset><legend>SQL</legend>
  <form onsubmit="execute(commands.value); return false">
    <textarea rows="10" cols="70" id="commands">CREATE TABLE my_table(key INTEGER, value INTEGER, text VARCHAR(100));
INSERT INTO my_table VALUES(1, 25, 'the first item');
INSERT INTO my_table VALUES(2, 987, 'the second item');

SELECT key, text FROM my_table WHERE value == 987;
</textarea>
</fieldset>
<p align=right>
    <input value="Explore on GitHub..." type="button" onclick="console.exec('x-www-browser https://github.com/kripken/sql.js');"> <input value="execute" type="submit" id=max></p>
  </form>
</body></html>
